<?php
/**
 * @copyright SYS Company
 * @author : Mr  Nguyễn Hoàng Long
 * @version : 1.0
 * @name : CRUD Class
 * @todo:  Lớp  mở rộng của CModule. Thao tác danh sách, sửa, xóa cơ sở.
*/
class KultechBanner extends CModule {
	/*
	 * output data
	 * */
	function draw() {
		$page = request('page');
		$currentMenu ='home';
		$currentSubMenu ='home';
		switch (request('page')) {
			case 'postbds':$currentMenu ='postbds';$currentSubMenu ='postbds';break;
			case 'bds':$currentMenu ='bds';$currentSubMenu ='bds';break;
			case 'listbds':$currentMenu ='bds';$currentSubMenu ='canban';break;
			case 'bdsdetail':$currentMenu ='bds';$currentSubMenu ='canban';break;
			case 'news':$currentMenu ='news';$currentSubMenu ='news';break;
			case 'newsdetail':$currentMenu ='news';$currentSubMenu ='news';break;
			case 'vbpl':$currentMenu ='vbpl';$currentSubMenu ='vbpl';break;
			case 'chitietvbpl':$currentMenu ='vbpl';$currentSubMenu ='vbpl';break;
			case 'canban':$currentMenu ='bds';$currentSubMenu ='canban';break;
			case 'canmua':$currentMenu ='bds';$currentSubMenu ='canmua';break;
			case 'canthue':$currentMenu ='bds';$currentSubMenu ='canthue';break;
			case 'chothue':$currentMenu ='bds';$currentSubMenu ='chothue';break;
			case 'daugia':$currentMenu ='bds';$currentSubMenu ='daugia';break;
			case 'chitietdaugia':$currentMenu ='bds';$currentSubMenu ='daugia';break;
			case 'duan':$currentMenu ='duan';$currentSubMenu ='duan';break;
			case 'chitietduan':$currentMenu ='duan';$currentSubMenu ='duan';break;
			case 'life':$currentMenu ='khampha';$currentSubMenu ='life';break;
			case 'chitietlife':$currentMenu ='khampha';$currentSubMenu ='life';break;
			case 'phongthuy':$currentMenu ='khampha';$currentSubMenu ='phongthuy';break;
			case 'chitietphongthuy':$currentMenu ='khampha';$currentSubMenu ='phongthuy';break;
			case 'kientruc':$currentMenu ='khampha';$currentSubMenu ='kientruc';break;
			case 'chitietkientruc':$currentMenu ='khampha';$currentSubMenu ='kientruc';break;
			case 'giaitri':$currentMenu ='khampha';$currentSubMenu ='giaitri';break;
			case 'intro':$currentMenu ='intro';$currentSubMenu ='intro';break;
		}
		$news_categories = CTable('news_category')->select_all();
		$admin_url = '';
		$user = user();
		if($user->is_admin()) {
			$admin_url = url('admin', array(), '', 'rewrite');
		} else if($user->is_login()) {
			foreach($user->privileges as $privileges) {
				foreach($privileges as $privilege=>$value) {
					if($privilege != 'Salesman') {
						$admin_url = url('admin', array(), '', 'rewrite');
						break;
					}
				}
			}
		}
		CForm($this->path().'/layout.tpl')->parse(array('admin_url'=>$admin_url,
														'currentMenu'=>$currentMenu,
														'currentSubMenu'=>$currentSubMenu,
														'news_categories'=>$news_categories
														)
													);
 	}
}